home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / basic / vidbasic.zip / VHERC.ASM < prev    next >
Assembly Source File  |  1990-11-29  |  7KB  |  184 lines

  1. ;«RM82»«TS8,16,24,32,40,48,56,64»
  2. ; Updated 11/20/90
  3.  
  4. ;============================================================================
  5. ;   Copyright (C) Copr. 1990 by Sidney J. Kelly
  6. ;           All Rights Reserved.
  7. ;           Sidney J. Kelly
  8. ;           150 Woodhaven Drive
  9. ;           Pittsburgh, PA 15228
  10. ;           home phone 412-561-0950 (7pm to 9:30pm EST)
  11. ;============================================================================
  12.  
  13.  
  14. DOSSEG
  15. .model medium, Basic
  16. .data
  17.     EXTRN  B$DVIDEOINSTL:BYTE       ; tell other routines
  18.                     ; that display has changed
  19. .code
  20.  
  21. ;============================================================================
  22. ; DECLARE SUB HERCMODE (BYVAL Mode%)
  23. ; CALL HERCMODE (Mode%)
  24. ; Input:
  25. ;       Mode =  0, Sets a Herc display to half-mode, so it can use a CGA
  26. ;       Mode <> 0, Sets a Herc display to full-mode, can not use a CGA
  27. ; Does not test for existence of Herc display
  28. ;============================================================================
  29. EVEN
  30. HERCMODE Proc FAR BASIC, MODE:WORD 
  31.     Mov    BL,3        ; assume will be Full mode
  32.     Mov    AX,MODE        ; read mode
  33.     OR    AL,AL        ; is MODE = 0?
  34.     JNZ    Start        ; no so jump ahead
  35.     Mov    BL,1        ; else select half mode
  36. Start:
  37.     Mov    AL,BL        ; get value from BL
  38.     Mov    DX,03BFh    ; HERC Port address
  39.     Out    DX,Al        ; send it to HERC
  40.     ;Mov    AX,7            ; mode change not necessary
  41.     ;Int    10h             ; unless want to clear display
  42.     Ret            ; MASM will remove the one parameter
  43. HERCMODE ENDP
  44.  
  45. ;============================================================================
  46. ; DECLARE SUB SWAPCOLOR ()
  47. ; CALL SWAPCOLOR
  48. ; Purpose:
  49. ;         If have a CGA and a MONO display, this makes the CGA active
  50. ; Note:
  51. ;         Does not test if have either CGA or MONO installed
  52. ; Side Effect: Display Cleared
  53. ;============================================================================
  54.  
  55. EVEN
  56. SWAPCOLOR Proc FAR BASIC
  57.     Xor    AX,AX
  58.     Mov     B$DVIDEOINSTL,AL        ; tell video routines that display
  59.                     ; has changed
  60.     Mov    ES,AX            ; set ES to BIOS ram
  61.     And     Byte Ptr ES:[0410h],11001111b ; clear CRT type equipment word
  62.     Or      Byte Ptr ES:[0410h],00100000b ; set 80 col. CGA
  63.     Mov    AX,3            ; reset video mode as that resets
  64.     Int    10h            ; internal parameters
  65.     Ret
  66. SWAPCOLOR ENDP
  67.  
  68. ;============================================================================
  69. ; DECLARE SUB SWAPMONO ()
  70. ; CALL SWAPMONO
  71. ; Purpose:
  72. ;         If have a CGA and a MONO display, this makes the MONO active
  73. ; Note:
  74. ;         Does not test if have either CGA or MONO installed
  75. ; Side Effect: Display Cleared
  76. ;============================================================================
  77.  
  78. EVEN
  79. SWAPMONO Proc FAR BASIC
  80.     Xor    AX,AX
  81.     Mov     B$DVIDEOINSTL,AL        ; tell video routines that display
  82.                     ; has changed
  83.     Mov     ES,AX                   ; set ES to BIOS ram
  84.     And     Byte Ptr ES:[0410h],11001111b ; clear CRT type equipment word
  85.     Or      Byte Ptr ES:[0410h],00110000b ; set mono display
  86.     Mov    AX,7            ; reset video mode as that resets
  87.     Int    10h            ; internal parameters
  88.     Call    FAR PTR DUALDISPLAY     ; see if we have dual displays
  89.     Or      AX,AX                   ; is AX = 0, (i.e. no dual displays)
  90.     JZ      Finis2                  ; if only one display, skip ahead
  91.     Xor     AX,AX                   ; set any HERC to compatible mode
  92.     Push    AX                      ; Push a zero on the stack
  93.     Call    FAR PTR HERCMODE        ; select HERC compatible mode
  94.                     ; should have no effect on other
  95.                     ; displays
  96. Finis2:
  97.     Ret
  98. SWAPMONO ENDP
  99.  
  100. ;============================================================================
  101. ; DECLARE FUNCTION FINDMONO% ()
  102. ; Returns:
  103. ;       True  (<> 0)  if mono CRT found, even if not active
  104. ;       False (0)     if mono CRT not found
  105. ;============================================================================
  106.  
  107. EVEN
  108. FINDMONO proc BASIC
  109.     Mov     DX,03B4h                ; mono CRTC index port
  110.     JMP     SHORT Main
  111. FINDMONO ENDP
  112.  
  113. ;============================================================================
  114. ; DECLARE FUNCTION FINDCOLOR% ()
  115. ; Returns:
  116. ;       True  (<> 0)  if color CRT found, even if not active
  117. ;       False (0)     if color CRT not found
  118. ;============================================================================
  119.  
  120. EVEN
  121. FINDCOLOR Proc  BASIC
  122.     Mov     DX,03D4h                ; color CRTC index port
  123. Main::
  124.     Mov     BX,-1                   ; assume will find display
  125.     Mov     AL,0Eh                  ; load cursor location high address
  126.     Out     DX,AL                   ; write to index port
  127.     INC     DX                      ; increment to port 03x5
  128.     IN      AL,DX                   ; read cursor location low
  129.     Mov     AH,AL                   ; store in AH
  130.     Mov     AL,71h                  ; select impossible value
  131.     Out     DX,AL                   ; write it
  132.     Jmp     $+2                     ; allow delay for slow ports
  133.     Jmp     $+2                     ; allow delay for slow ports
  134.     Jmp     $+2                     ; allow delay for slow ports
  135.     Jmp     $+2                     ; allow delay for slow ports
  136.     Jmp     $+2                     ; allow delay for slow ports
  137.     Jmp     $+2                     ; allow delay for slow ports
  138.     Jmp     $+2                     ; allow delay for slow ports
  139.     Jmp     $+2                     ; allow delay for slow ports
  140.     In      AL,DX                   ; read value we just wrote
  141.     XCHG    AH,AL                   ; get back original value
  142.     Jmp     $+2                     ; allow delay for slow ports
  143.     Out     DX,AL                   ; write it
  144.     CMP     AH,71h                  ; did we get back 71h?
  145.     JE      Finis                   ; yes, so CRT is there
  146.     Xor     BX,BX                   ; report CRT not there
  147.  
  148. Finis:
  149.     Mov     AX,BX                   ; store result in AX
  150.     Xor     DX,DX                   ; so can be called long
  151.     RET
  152. FINDCOLOR   ENDP
  153.  
  154. ;============================================================================
  155. ; DECLARE FUNCTION DUALDISPLAY% ()
  156. ; Returns:
  157. ;       True  (<> 0)  if two dislays found
  158. ;       False (0)     if only one CRT found
  159. ;============================================================================
  160.  
  161. EVEN
  162. DUALDISPLAY Proc BASIC USES SI
  163.     Xor    AX,AX
  164.     Mov    SI,AX            ; clear SI and use as counter
  165.     Call    FAR PTR FINDCOLOR       ; see if color CRT installed
  166.     Or    AX,AX            ; if AX = 0 then no color
  167.     JZ    Next_Display
  168.     Inc    SI            ; report color display found
  169. Next_Display:
  170.     Call    FAR PTR FINDMONO        ; see if mono CRT installed
  171.     Or    AX,AX
  172.     JZ    Wrap_up
  173.     Inc    SI            ; report mono CRT found
  174. Wrap_up:
  175.     Xor    AX,AX            ; assume only one CRT
  176.     Cmp    SI,2            ; were two found?
  177.     JNE    Finis            ; nope
  178.     Mov    AX,-1            ; report yes
  179. Finis:
  180.     Xor    DX,DX            ; so can be called long
  181.     Ret
  182. DUALDISPLAY ENDP
  183. END
  184.